package cn.edu.sdjzu.xg.eagle.service.impl;

import cn.edu.sdjzu.xg.eagle.entities.Student;
import cn.edu.sdjzu.xg.eagle.mapper.StudentMapper;
import cn.edu.sdjzu.xg.eagle.service.inface.StudentService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class StudentImpl implements StudentService {

    @Autowired
    private StudentMapper studentMapper;

    @Override
    public Student getStudentById(Integer id) {
        return studentMapper.getStudentById(id);
    }

    @Override
    public List<Student> getStudents() {
        return studentMapper.getStudents();
    }

    @Override
    public String addStudent(Student student) {
        if (studentMapper.addStudent(student)) {
            return "添加student成功";
        } else {
            return "添加student失败";
        }
    }

    @Override
    public String updateStudent(Student student) {
        if (studentMapper.updateStudent(student)) {
            return "修改student成功";
        } else {
            return "修改student失败";
        }
    }

    @Override
    public String deleteStudent(Integer id) {
        if (studentMapper.deleteStudent(id)) {
            return "删除student成功";
        } else {
            return "删除student失败";
        }
    }
}